#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i <= r; ++i)
const int N = 1e3 + 7;
int a[N], n;
bool ok = 1;
vector<int> ans;

void in(int x) {
    if (x <= n && a[x] != -1) {
        in(x * 2);
        ans.push_back(a[x]);
        in(x * 2 + 1);
    }
}
int main() {
    scanf("%d", &n);
    rep(i, 1, n) scanf("%d", &a[i]);
    rep(i, 1, n) {
        if (a[i] != -1) {
            if (i * 2 <= n) {
                if (a[i * 2] != -1 && a[i * 2] >= a[i]) ok = 0;
            }
            if (i * 2 + 1 <= n) {
                if (a[i * 2 + 1] != -1 && a[i * 2 + 1] < a[i]) ok = 0;
            }
        } else {
            if (i * 2 <= n && a[i * 2] != -1) ok = 0;
            if (i * 2 + 1 <= n && a[i * 2 + 1] != -1) ok = 0;
        }
        if (!ok) break;
    }
    puts(ok ? "YES" : "NO");
    in(1);
    int len = ans.size() - 1;
    rep(i, 0, len) printf("%d%c", ans[i], i == len ? '\n' : ' ');
    return 0;
}